﻿using B.S.BaseData.Api.Write.Applicantion.Command.HospitalCommand;
using B.S.BaseData.ErrorCode;
using B.S.BaseData.Infrastructure.Implement;
using B.S.BaseData.Infrastructure.Interface;
using B.S.BataBase.Domain.AI;
using MediatR;

namespace B.S.BaseData.Api.Write.Applicantion.CommandHandler.HospitalCommandHandler
{
    public class HistoryOfMedicalVisitsDeleteCommandHandler : IRequestHandler<HistoryOfMedicalVisitsDeleteCommand, APIResult<int>>
    {
        private readonly IBaseRepository<HistoryOfMedicalVisitsModel> _repository;
        public HistoryOfMedicalVisitsDeleteCommandHandler(IBaseRepository<HistoryOfMedicalVisitsModel> repository)
        {
            _repository=repository; 
        }
        public async Task<APIResult<int>> Handle(HistoryOfMedicalVisitsDeleteCommand request, CancellationToken cancellationToken)
        {
            APIResult<int> result = new APIResult<int>();
            var list = await _repository.GetValues(x => x.Id == request.Id);
            list.IsDel = true;
            var data = await _repository.UpdateAsync(list);
            result.Code = ApiEnum.Fail;
            result.Msg = "就诊记录删除成功";
            result.Data = data;
            return await Task.FromResult(result);
        }
    }
}
